<?php
class IndexAction extends Action{
	public function index(){
		$this->display();
	}
	public function do_index(){
		$username=$this->_post('username');
		$password=md5($this->_post('password'));
		$user=M('users');
		$res=$user->field('UserId,TrueName')->where('UserName="'.$username.'" and Password = "'.$password.'" and (UserType=6 or UserType=7)')->find();

		if($res){
			$_SESSION['UserName']=$username;
			$_SESSION['UserId']=$res['UserId'];
			$_SESSION['TrueName']=$res['TrueName'];
			$this->success('登陆成功','init');
		}else{
			$this->error('登陆失败','index');
		}
	}
	public function init(){
		$user=M('users');
		$team=M('team');
		$time=M('time');
		$team=M('team');
		$enter=M('enterprise');
		$tlist=$time->find();
		$total1=$user->where('UserType=1')->count();
		$stotal=$user->where('UserType=2')->count();
		$yttotal=$user->where('UserType=3 and IsApproved=1')->count();
		$wttotal=$user->where('UserType=3 and IsApproved=0')->count();
		$ymtotal=$user->where('UserType=4 and IsApproved=1')->count();
		$wmtotal=$user->where('UserType=4 and IsApproved=0')->count();
		$jtotal=$user->where('IsJury=1')->count();
		$tnum=$team->count();
		$this->assign('stotal',$stotal);
		$this->assign('total1',$total1);
		$this->assign('yttotal',$yttotal);
		$this->assign('wttotal',$wttotal);
		$this->assign('ymtotal',$ymtotal);
		$this->assign('wmtotal',$wmtotal);
		$this->assign('yttotal',$jtotal);
		$this->assign('tnum',$tnum);
		$this->assign('tlist',$tlist);
		$this->display();
	}
}
